/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-06
 * Time: 20:37
 */
public class Test {
    public class PalindromeList {
        public boolean chkPalindrome(ListNode A) {
            // write code here
           ListNode fast = A;
            ListNode slow = A;

            while (fast != null && fast.next != null) {

                fast = fast.next.next;

                slow = slow.next;

            }

            ListNode cur = slow.next;

            while (cur != null) {

                ListNode curNext = cur.next;

                cur.next = slow;

                slow = cur;

                cur = curNext;


            }



            while (slow !=A) {

                if (slow.val != A.val) {

                    return false;

                }

                //偶数情况

                if (A.next == slow) {

                    return true;

                }

                A = A.next;

                slow = slow.next;

            }

            return true;

        }



    }



    public static void main(String[] args) {

    }
}
